<?php

App::uses('AppHelper', 'View/Helper');
App::import('Model', 'Category');

/**
 * Application helper
 *
 * Add your application-wide methods in the class below, your helpers
 * will inherit them.
 *
 * @package       app.View.Helper
 */
class CategoriesHelper extends AppHelper {
	public $helpers = array('Html');

	public function getMenuCategories(){
		$category = new Category();
		$category->recursive = -1;
		$categories = $category->find('all', array( 'fields' => array('id', 'name', 'slug'),
																								'order' => 'order',
																								'conditions' => array('auto_show' => Category::autoShow,
																																			'level' => 1)));
		return $categories;
	}

	public function getSeoUrl($categoryId){
		$Category = new Category();
		$realPath = $Category->getPath($categoryId, array('id', 'slug'), -1);
		$url = "";
		foreach($realPath as $item){
			$url .= "/" . $item['Category']['slug'];
		}
		return $url;
	}
}
